package LW.com.Db;

import java.sql.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.*;

public class DBconnetion {
	
	private DataSource datasource;

	public DBconnetion() {
		try{
		Context context = new InitialContext();
		datasource = (DataSource)context.lookup("java:comp/env/jdbc/aaa");
		}
		catch(Exception e){
			System.out.println("DBconnect has error : "+ e.toString());
		}
	}
	
	public Connection getConnection(){
		try {
			return datasource.getConnection();
		} catch (Exception e) {
			System.out.println("Db getconnection has error : "+ e.toString());
		}
		return null;
	}
	
}
